<template>
    <a-tabs type="card">
      <a-tab-pane tab="待审核出厂检测信息" key="1">

        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :md="6" :sm="8">
                <a-form-item label="合同号">
                  <a-input placeholder="请输入合同号" v-model="queryParam.contractNumber"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="8">
                <a-form-item label="屏号">
                  <a-input placeholder="请输入屏号" v-model="queryParam.productNo"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="8" >
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              </span>
              </a-col>

            </a-row>
          </a-form>
        </div>
        <!-- 查询区域-END -->

        <!-- 操作按钮区域 -->
        <div class="table-operator">
          <a-button @click="handleReview()" type="primary" icon="plus">批量审核</a-button>
        </div>

        <!-- table区域-begin -->
        <div>
          <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
            <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
            <a style="margin-left: 24px" @click="onClearSelected">清空</a>
          </div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="productNo"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            filterMultiple="true"
            :loading="loading"
            :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            @change="handleTableChange">
            <template slot="action" slot-scope="text, record">
              <a @click="handleReview(record)">审核</a>
            </template>
          </a-table>
        </div>
      </a-tab-pane>
      <a-tab-pane tab="已审核出厂检测信息" key="2">
            <zxjEip2cCcjc-list-over  ref="modalForm" @ok="modalFormOk"></zxjEip2cCcjc-list-over>
        </a-tab-pane>
    </a-tabs>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ZxjEip2cCcjcModal from './modules/ZxjEip2cCcjcModal'
  import ZxjEip2cCcjcListOver from './ZxjEip2cCcjcListOver'
  import { deleteAction,postAction,getAction,downFile } from '@/api/manage'

  export default {
    name: "ZxjEip2cCcjcList",
    mixins:[JeecgListMixin],
    components: {
      ZxjEip2cCcjcModal,
      ZxjEip2cCcjcListOver
    },
    data () {
      return {
        description: '出厂检测管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'合同号',
            align:"center",
            dataIndex: 'contractNumber'
          },
          {
            title:'屏号',
            align:"center",
            dataIndex: 'productNo'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/apis/zxjEip2cCcjc/list",
          review:"/apis/zxjEip2cCcjc/review"
        },
        dictOptions:{
        } 
      }
    },
    methods: {
      initDictConfig(){
      },
      handleDetail:function(record){
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title="详情";
        this.$refs.modalForm.disableSubmit = true;
      },
      handleReview:function(record) {
         let param={data:[]};
            if (record){
                 param.data.push({'contractNumber':record.contractNumber,'productNo':record.productNo})
            }else {
              if (this.selectionRows.length <= 0) {
                this.$message.warning('请选择一条记录！');
                return;
              } else {
                for (var a = 0; a < this.selectionRows.length; a++) {
                  param.data.push({'contractNumber':this.selectionRows[a].contractNumber,'productNo':this.selectionRows[a].productNo})
                }
              }
            }
        var that = this;
        this.$confirm({
          title: "审核",
          content: "是否确认审核通过选中的数据?",
          onOk: function () {
            postAction(that.url.review,param.data).then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.loadData();
                that.onClearSelected();
              } else {
                that.$message.warning(res.message);
              }
            });
          }
        });
      }
    }
  }
</script>